package com.myprocessing.box.button.drag;

import java.util.List;

import com.myprocessing.action.Action;
import com.myprocessing.gui.util.Coord;

public class DragPositionManager {

	protected List<DragCoord> dragCoord;
	protected Action endDragAction;
	protected Action startDragAction;

	public List<DragCoord> getDragCoord() {
		return dragCoord;
	}

	public void setDragCoord(List<DragCoord> dragCoord) {
		this.dragCoord = dragCoord;
	}
	
	public Coord getValidCoord(Coord coord){
		Coord result = null;
		
		for(DragCoord rc: dragCoord){
			if(rc.isValid(coord)){
				result = (Coord)rc;
				break;
			}
		}
		
		return result;
	}
	
	public void execStartDrag(Coord coord){
		Action.executeAction(startDragAction);
	}
	
	public void execEndDrag(Coord coord){
		Action.executeAction(endDragAction);
	}

	public Action getEndDragAction() {
		return endDragAction;
	}

	public void setEndDragAction(Action endDragAction) {
		this.endDragAction = endDragAction;
	}

	public Action getStartDragAction() {
		return startDragAction;
	}

	public void setStartDragAction(Action startDragAction) {
		this.startDragAction = startDragAction;
	}
}
